home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / gxmatrix.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-27  |  2.8 KB  |  77 lines

  1. /* Copyright (C) 1989, 1995, 1996, 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxmatrix.h */
  20. /* Internal matrix routines for Ghostscript library */
  21.  
  22. #ifndef gxmatrix_INCLUDED
  23. #  define gxmatrix_INCLUDED
  24.  
  25. #include "gsmatrix.h"
  26.  
  27. /*
  28.  * Define a matrix with a cached fixed-point copy of the translation.
  29.  * This is only used by a few routines in gscoord.c; they are responsible
  30.  * for ensuring the validity of the cache.  Note that the floating point
  31.  * tx/ty values may be too large to fit in a fixed values; txy_fixed_valid
  32.  * is false if this is the case, and true otherwise.
  33.  */
  34. typedef struct gs_matrix_fixed_s {
  35.     _matrix_body;
  36.     fixed tx_fixed, ty_fixed;
  37.     bool txy_fixed_valid;
  38. } gs_matrix_fixed;
  39.  
  40. /* Coordinate transformations to fixed point. */
  41. int gs_point_transform2fixed(P4(const gs_matrix_fixed *, floatp, floatp,
  42.                 gs_fixed_point *));
  43. int gs_distance_transform2fixed(P4(const gs_matrix_fixed *, floatp, floatp,
  44.                    gs_fixed_point *));
  45.  
  46. /*
  47.  * Define the fixed-point coefficient structure for avoiding
  48.  * floating point in coordinate transformations.
  49.  * Currently this is used only by the Type 1 font interpreter.
  50.  * The setup is in gscoord.c.
  51.  */
  52. typedef struct {
  53.     long l;
  54.     fixed f;
  55. } coeff1;
  56. typedef struct {
  57.     coeff1 xx, xy, yx, yy;
  58.     int skewed;
  59.     int shift;            /* see m_fixed */
  60.     int max_bits;            /* max bits of coefficient */
  61.     fixed round;            /* ditto */
  62. } fixed_coeff;
  63. /*
  64.  * Multiply a fixed whose integer part usually does not exceed max_bits
  65.  * in magnitude by a coefficient from a fixed_coeff.
  66.  * We can use a faster algorithm if the fixed is an integer within
  67.  * a range that doesn't cause the multiplication to overflow an int.
  68.  */
  69. #define m_fixed(v, c, fc, maxb)\
  70.   (((v) + (fixed_1 << (maxb - 1))) &\
  71.     ((-fixed_1 << maxb) | _fixed_fraction_v) ?    /* out of range, or has fraction */\
  72.    (fixed2int_var(v) * (fc).c.f +\
  73.     arith_rshift(fixed_fraction(v) * (fc).c.f + fixed_half, _fixed_shift)) :\
  74.    arith_rshift(fixed2int_var(v) * (fc).c.l + (fc).round, (fc).shift))
  75.  
  76. #endif                    /* gxmatrix_INCLUDED */
  77.